package com.zxxnj.MyThreadPool;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

public class MyRejectedExecutionHandler implements RejectedExecutionHandler {
     private RejectedExecutionHandler my;

    public MyRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler) {
        my = rejectedExecutionHandler;
    }

    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        if ((executor.getQueue() instanceof MyTaskQueue) && ((MyTaskQueue) executor.getQueue()).force(r)) {
            return;
        }
        my.rejectedExecution(r, executor);
    }
}
